Skip to content

Add PR preview pruning and retention management#378

Open
Yashisinghal285 wants to merge 5 commits into
layer5io:masterfrom
Yashisinghal285:issue-377-preview-pruning
Open

Add PR preview pruning and retention management#378
Yashisinghal285 wants to merge 5 commits into
layer5io:masterfrom
Yashisinghal285:issue-377-preview-pruning

Conversation

@Yashisinghal285

Copy link
Copy Markdown
Contributor

Description

This PR adds preview pruning and retention management for PR preview deployments.

What changed

  • Adds PREVIEW_RETENTION_LIMIT = 6
  • Implements pruning of old pr-preview/pr-* directories
  • Uses sparse checkout for efficient gh-pages maintenance
  • Ensures only 6 most recent previews are kept
  • Adds notifications when previews are pruned
  • Preserves cleanup-on-close behavior

Issue

Fixes #377

Notes for Reviewers

  • Workflow runs after PR preview deployment
  • Only gh-pages pr-preview directory is modified
  • Safe for concurrent PR workflows

Checklist

  • I tested the workflow locally / validated syntax
  • I understand this modifies GitHub Actions behavior

Signed commits

  • Yes, I signed my commits

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

🚀 Preview deployment: https://layer5io.github.io/getnighthawk/pr-preview/pr-378/

Note: Preview may take a moment (GitHub Pages deployment in progress). Please wait and refresh. Track deployment here

@Yashisinghal285

Copy link
Copy Markdown
Contributor Author

Hi maintainers 👋
This PR implements preview pruning and retention management as per #377.
Ready for review when convenient.

leecalcote and others added 2 commits June 20, 2026 00:33
Signed-off-by: l5io <ci@layer5.io>
Signed-off-by: Yashi Singhal285 <yashi.singhal410@gmail.com>
Signed-off-by: Yashi Singhal285 <yashi.singhal410@gmail.com>
@Yashisinghal285 Yashisinghal285 force-pushed the issue-377-preview-pruning branch from 831bd43 to 2732b56 Compare June 19, 2026 19:05
@Yashisinghal285

Copy link
Copy Markdown
Contributor Author

Hi maintainers 👋

I noticed the failing lint check appears to be timing out during package loading (context deadline exceeded).

This PR only modifies build-and-preview-site.yml and docs/_data/discuss/nighthawk.json, and does not modify .github/workflows/ci.yml, which runs the lint job.

Please let me know if you'd like any changes from my side or if there is anything else I can help investigate.

Thanks! 🙌

<center><h1>301 Moved Permanently</h1></center>
<hr><center>cloudflare</center>
</body>
</html>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is use of changing this file.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bhumikagarggg Thanks for pointing this out. This file wasn't intentionally modified as part of the preview pruning feature. It changed while I updated my branch and resolved the merge conflict with the latest master. The functional changes for this PR are only in build-and-preview-site.yml.

@Bhumikagarggg

Copy link
Copy Markdown

I approved this PR by mistake.


jobs:
build-and-deploy-preview:
outputs:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move output section after runs-on

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bhumikagarggg Done, thank you for the suggestion. I've moved the outputs section below runs-on as requested. Could you please take another look when you have a chance?


git add pr-preview
git commit -m "Prune old PR previews" || true
git push || true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace git push || true with git push instead of ignoring push failures.

@Yashisinghal285

Copy link
Copy Markdown
Contributor Author

@Sbragul26 Thanks for the review! I've updated the workflow by replacing git push || true with git push as suggested. Please take another look when you have a chance.

git config user.email "github-actions[bot]@users.noreply.github.com"

git add pr-preview
git commit -m "Prune old PR previews" || true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this too replace git commit -m "Prune old PR previews" with this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! I've removed || true from the git commit command since the workflow already checks for staged changes before attempting the commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pruning for PR preview deployments

4 participants